Dim Shell, fullPath, regValue,valueType  
Set Shell = CreateObject("WScript.Shell")
fullPath = "HKEY_CURRENT_USER\Software\MyApp"	
valueName="PADS_SHORTCUTS_ROOT"
root = Shell.RegRead(fullPath & "\" & valueName)

Dim folderPath, fileNamePattern, fso, folder, file, found, matches
folderPath = root & "\skill\B"
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(folderPath)

fullPath = "HKEY_CURRENT_USER\Software\MyApp"	
valueName="PADS_Command"
valueType = "REG_SZ"

Dim cmdparam 
cmdparam = Shell.RegRead(fullPath & "\PreCmd")
'msgbox cmdparam
fileNamePattern = cmdparam & ".mcr"
For Each file In folder.Files
	'msgbox file.name
	If LCase(file.Name) = LCase(fileNamePattern) Then
		Application.RunMacro(file.path,"")
		Shell.RegWrite fullPath & "\PreCmd", cmdparam, valueType
		cmdparam =""
		Exit For
	End If
Next


